package com.kb.design.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.google.common.base.Objects;

/**
 * @Auther:chenzx
 * @Date:2024-01-30
 * @Description:项目状态枚举
 */
public enum DesignNodeStatus {
    /**
     * 布局
     * 布局确认
     * 布线
     * 布线优化
     * 布线确认
     * 后处理
     */
    LAYOUT("布局", "1"),
    LAYOUT_CHECK("布局评审", "2"),
    MODIFY_LAYOUT_OPINIONS("修改布局评审意见", "3"),
    WIRING("布线", "4"),
    POST_PROCESSING("丝印、后处理", "5"),
    WIRING_REVIEW("布线评审", "6"),
    MODIFY_WIRING_OPINIONS("修改布线评审意见", "7"),
    CHECK_LIST("Checklist QA检查", "8");

    private String name;
    @EnumValue
    private String index;

    public DesignNodeStatus next() {
        DesignNodeStatus[] statuses = DesignNodeStatus.values();
        int ordinal = this.ordinal();
        if (ordinal < statuses.length - 1) {
            return statuses[ordinal + 1];
        } else {
            return null; // 处理逻辑，表示已是最后一个状态
        }
    }

    public static DesignNodeStatus getNextStatusByIndex(int index) {
        for (DesignNodeStatus status : DesignNodeStatus.values()) {
            if (Integer.parseInt(status.index) == index) {
                return status.next();
            }
        }
        return null; // 如果没有找到对应状态，返回null
    }

    // 构造方法
    DesignNodeStatus(String name, String index) {
        this.name = name;
        this.index = index;
    }

    // 普通方法
    public static String getName(String index) {
        for (DesignNodeStatus c : DesignNodeStatus.values()) {
            if (Objects.equal(index, c.getIndex())) {
                return c.name;
            }
        }
        return null;
    }

    // get set 方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIndex() {
        return index;
    }

    public void setIndex(String index) {
        this.index = index;
    }
}
